﻿<UserControl x:Class="SLAdmin.UserControls.EditStudyWave"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:extended="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:liquid="clr-namespace:Liquid;assembly=Liquid"
    xmlns:images="clr-namespace:SLAdmin.Images"    
    xmlns:extensions="clr-namespace:SLExtensions.Controls;assembly=SLExtensions.Controls"    
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
             LayoutUpdated="UserControl_LayoutUpdated"
             >
    <Grid x:Name="LayoutRoot" Style="{StaticResource MainDockBackground2}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="100"/>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="50"/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="130" />
                    <ColumnDefinition Width="1*"/>
                </Grid.ColumnDefinitions>
                <Image Grid.Column="0" Margin="10" Source="icons/Column-Chart-128x128.png" />
                <TextBox Grid.Column="1" Text="{Binding StudyWaveName, Mode=TwoWay}" Style="{StaticResource TextBoxMainHeadline}"/>
            </Grid>
            <Border Grid.Row="2" Style="{StaticResource BorderBottomPanel}">
                <Button x:Name="btnSave" 
                        Style="{StaticResource Button_Save}"                    
                        Click="btnSave_Click">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="icons/filesave-32.png"/>
                        <TextBlock Margin="5,0,0,0"
                               VerticalAlignment="Center" 
                               Text="Save"/>
                    </StackPanel>
                </Button>
            </Border>
            <extended:TabControl x:Name="StudyTabs" Grid.Row="1">
                <extended:TabItem Padding="5">
                    <extended:TabItem.Header>
                        <StackPanel Margin="5" Orientation="Horizontal">
                            <Image Source="icons/configure_32.png"/>
                            <TextBlock Text="General" 
                                   Style="{StaticResource TextBlockTabName}"
                                   />
                        </StackPanel>
                    </extended:TabItem.Header>
                    <extensions:DockPanel Style="{StaticResource DockMainTabPage}">
                        <ScrollViewer Style="{StaticResource ScrollViewerTabWindow}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="30"/>
                                    <RowDefinition Height="30"/>
                                    <RowDefinition Height="30"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="150"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" Style="{StaticResource TextBlockItemLabel}" 
                                               Grid.Row="0" Text="Variable Name Prefix"/>
                                <TextBox Grid.Column="1" 
                                               Grid.Row="0" Style="{StaticResource TextBoxSingleLineInputShort}"                               
                                               Text="{Binding VariableNamePrefix, Mode=TwoWay}"
                                               />
                            </Grid>
                        </ScrollViewer>
                    </extensions:DockPanel>
                </extended:TabItem>
                <extended:TabItem Padding="5">
                    <extended:TabItem.Header>
                        <StackPanel Margin="5" Orientation="Horizontal">
                            <Image Source="icons/survey.png"/>
                            <TextBlock Text="Surveys" 
                                   Style="{StaticResource TextBlockTabName}"
                                   />
                        </StackPanel>
                    </extended:TabItem.Header>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="1*"/>
                            <RowDefinition Height="85"/>
                        </Grid.RowDefinitions>
                        <Border Grid.Row="1" Style="{StaticResource BorderTabBottomPanelNoHeight}"
                                VerticalAlignment="Stretch">
                            <Grid VerticalAlignment="Stretch">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Button x:Name="btnCreateSurvey" VerticalAlignment="Top"
                                        Click="btnCreateSurvey_Click" Grid.Column="0"
                                        Style="{StaticResource ButtonMedium}">
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="icons/Survey.png"/>
                                        <TextBlock Text="New Survey" 
                                           Margin="5,0,0,0" 
                                           VerticalAlignment="Center" />
                                    </StackPanel>
                                </Button>
                                <StackPanel Orientation="Vertical" Grid.Column="1" VerticalAlignment="Top"
                                            HorizontalAlignment="Left">
                                    <ComboBox x:Name="ddlSurveys" VerticalAlignment="Top"
                                              HorizontalAlignment="Left"
                                                         Margin="5" DisplayMemberPath="SurveyName"                                            
                                                         Width="300"/>
                                    <Button x:Name="SurveyAdd" Margin="5" 
                                            HorizontalAlignment="Left"
                                            Click="SurveyAdd_Click" Style="{StaticResource ButtonMedium}">
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="icons/Survey.png"/>
                                            <TextBlock Text="Add Survey" 
                                                   Margin="5,0,0,0" 
                                                   VerticalAlignment="Center" />
                                        </StackPanel>
                                    </Button>
                                </StackPanel>
                            </Grid>
                        </Border>
                        <ScrollViewer Grid.Row="0" Style="{StaticResource ScrollViewerTabWindow}">
                            <data:DataGrid x:Name="SurveyGrid"
                                               AutoGenerateColumns="False"
                                                
                                                HeadersVisibility="None"
                                                RowBackground="White" HorizontalAlignment="Stretch"
                                                AlternatingRowBackground="LightGray"
                                                CanUserResizeColumns="False"                                                
                                                RowHeight="45">
                                <data:DataGrid.Columns>
                                    <data:DataGridTemplateColumn Width="34">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Source="icons/Page.png" Margin="3" />
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>
                                    <data:DataGridTextColumn MinWidth="200" Width="Auto" 
                                                                 Binding="{Binding SurveyName, Mode=TwoWay}"/>
                                    <data:DataGridTemplateColumn Width="400">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <Button Margin="5" x:Name="Up" Click="Up_Click">
                                                        <images:UpIcon ></images:UpIcon>
                                                    </Button>
                                                    <Button Margin="5" x:Name="Down" Click="Down_Click">
                                                        <images:DownIcon></images:DownIcon>
                                                    </Button>
                                                    <Button Margin="5" x:Name="Delete" Click="Delete_Click">
                                                        <images:DeleteIcon/>
                                                    </Button>
                                                </StackPanel>
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>
                                </data:DataGrid.Columns>
                            </data:DataGrid>
                        </ScrollViewer>
                    </Grid>
                </extended:TabItem>
            </extended:TabControl>
        </Grid>
    </Grid>
</UserControl>
